package cn.com.oceansoft.osc.ms.controller;

import cn.com.oceansoft.osc.ms.schedule.entity.paras;
import cn.com.oceansoft.osc.ms.schedule.entity.parasalarmresult;
import cn.com.oceansoft.osc.ms.schedule.entity.paraschat;
import cn.com.oceansoft.osc.ms.service.ICallPoliceService;
import cn.com.oceansoft.osc.ms.utils.XMLUtil;
import cn.ucox.web.framework.view.ApiResult;
import io.swagger.annotations.Api;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


import javax.annotation.Resource;
import java.util.Map;

import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;

/**
 * Created by caobo on 2017/7/8.
 */
//@Controller
//@RequestMapping(value = "callpolice/calp")
//@Api(value = "报警结果反馈", description = "报警服务接口")
public class CallPoliceController {
    @Resource
    ICallPoliceService iCallPoliceService;

    @ResponseBody
    @RequestMapping(value = "version", method = GET)
    public ApiResult version()
    {
        String version="0.02";
        return  new ApiResult<Object>().success(version);
    }

    /**
     * 添加反馈结果信息
     *
     * @param map
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "insert-resultjson", method = POST)
    public ApiResult insertResult(@RequestBody Map<String, String> map) {
       return iCallPoliceService.getResult(map);
    }


    /**
     * 返送微信获取结果
     *功能描述：110系统调用省厅微信分流接口，返送微信报警获取的结果
     * @param
     * @return
     */
    @ResponseBody()
    @RequestMapping(value = "OS_AcceptWeChatAlarmResult", method = POST)
    public String  alarmResultxml(@RequestBody String str) {
        //paras paras=(paras)XMLUtil.convertXmlStrToObject(paras.class,str);
        parasalarmresult paras=(parasalarmresult) XMLUtil.toBean(str,parasalarmresult.class);
        return iCallPoliceService.getAlarmResultxml(paras);
    }
    /**
     * 添加反馈结果信息
     *
     * @param
     * @return
     */
    @ResponseBody()
    @RequestMapping(value = "OS_AcceptProcessedResult", method = POST)
    public String  insertResultxml(@RequestBody String str) {
        //paras paras=(paras)XMLUtil.convertXmlStrToObject(paras.class,str);
        paras paras=(paras) XMLUtil.toBean(str,paras.class);
        return iCallPoliceService.getResultxml(paras);
    }


    /**
     * 添加指挥中心收到信息之后的返回结果接口
     *
     * @param map
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "updat-alarmState", method = POST)
    public ApiResult updatealarmstate(@RequestBody Map<String, String> map) {
        return iCallPoliceService.updatealarmstate(map);
    }


    /**
     * 添加会话内容接口
     *
     * @parammap
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "InsertIoChatjson", method = POST)
    public ApiResult InsertIoChat(@RequestBody Map<String, String> map) {
        return iCallPoliceService.InsertIoChat(map);
    }

    /**
     * 添加会话内容接口XML
     *
     * @parammap
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "InsertIoChat", method = POST)
    public String InsertIoChat(@RequestBody String str) {
        paraschat paras=(paraschat) XMLUtil.toBean(str,paraschat.class);
        return iCallPoliceService.InsertIoChatxml(paras);
    }
}
